home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11893 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  55 lines

  1. Path: pop.gnn.com!HoangTQ
  2. From: Tuyen Hoang <HoangTQ@gnn.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Derived class not calling overloaded base class function
  5. Date: Sat, 16 Mar 1996 17:26:03
  6. Organization: GNN
  7. Message-ID: <4iff2g$p2i@news-e2b.gnn.com>
  8. References: <4g46t2$3vd@otis.netspace.net.au> <Dn3778.CK1@news.arco.com>
  9. NNTP-Posting-Host: www-41-87.gnn.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset="us-ascii"
  12. X-GNN-NewsServer-Posting-Date: 16 Mar 1996 22:24:16 GMT
  13. X-Mailer: GNNmessenger 1.2
  14.  
  15. an illustration
  16. goo angoo;
  17. angoo.foo::get(); //now the get(void) in foo gets called
  18.  
  19. If you hate this syntax -I do- and want to use angoo.get() to call the base 
  20. class function, you need to do one *easy* thing: add the follow line into 
  21. your definition of class goo
  22.  
  23. class goo : public foo{
  24. //...
  25. void get() { foo::get() ; }
  26. //...
  27. };
  28.  
  29. that's all, but the concept is not easy. If you want some explanation, you 
  30. should look back the thread and the FAQ. As my experience, I usually need an 
  31. illustration before I can understand the theorical explanation.
  32.  
  33. Then this is my question
  34.  Do we need a more elegant way than this work around. I want to have a way to 
  35. say to the compiler that I do not declare a new function-inlining and calling 
  36. the base function- but notify that the base function is now _unhiding_ from 
  37. the derived overloaded function, something look like
  38.  
  39. class derived : public base{
  40. //....
  41.     public:
  42.        void get(int);
  43.   /* unhiding */ void base::get();
  44. //....
  45. };
  46.  
  47. the problem is not concern about one or more overhead calls but the concept 
  48. that the base function is now *explicit* present in the derived class and can 
  49. be overloaded as it was declared here. Does the virtual key word is 
  50. needed/no needed?
  51.  
  52. Regard
  53. Tuyen Hoang
  54.  
  55.